import React from 'react'
class ParentNode extends React.Component{
  constructor(props) {
    super(props)
    this.inputRef = React.createRef()
  }
  render() {
    return (
      <div>
        parent:
        <ChildNode inputRef={this.inputRef} />
        <button onClick={() => this.inputRef.current.focus()}>click</button>
      </div>
    )
  }
}
class ChildNode extends React.Component{
  render() {
    return (
      <input ref={this.props.inputRef} />
    )
  }
}

export default ParentNode
